package com.github.CharlesSong.exception;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Description:
 * Author: CharlesSong
 * Date  : 2015/8/10
 */
public class CommonExceptionResolver implements HandlerExceptionResolver {

    private Log log= LogFactory.getLog(CommonExceptionResolver.class);
    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {

        httpServletResponse.setCharacterEncoding("UTF-8");

        ModelAndView mv = new ModelAndView();

        String error=e.getMessage();

        mv.setViewName("/error");
        mv.addObject("exception", e.getMessage());

        return mv;
    }

}
